<%@ page import="com.chazz.entity.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<% User user= (User) session.getAttribute("user"); %>
<head>
    <meta charset="UTF-8">
    <title>信息修改</title>
    <style>
        #container{
            width: 950px;
        }
        #upForm{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        #upForm p{
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <container id="container">
        <article id="article">
            <form  id="upForm">
                <p>
                    <input type="hidden" name="email" id="email" value="${user.getEmail()}">
                </p>
            <p>
                <span>用户姓名：</span><input type="text" name="userName" id="userName" value="">
            </p>
            <p>
                <span>用户电话：</span><input type="text" name="userPhone" id="userPhone" value="">
            </p>
            <p>
                <span>性别：</span><input type="radio" name="sex" class="sexRadio" value="0" id="man">男&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sex" class="sexRadio" value="1" id="faman">女
            </p>
                <p>
            <input type="button" id="sub" value="提交">
                </p>
            </form>
        </article>
    </container>
<script src="js/jquery-3.5.1.js"></script>
    <script src="js/updateInfo.js"></script>
<script>
    $(document).ready(function () {
        userInfoList();
        //$("#sub").click(updateInfo);
        $("#sub").on("click",function () {
            $.ajax({
                "url":"user2.do",
                "type":"get",
                "datatype":"json",
                "data":{
                    "option":"userUpdate",
                    "email":$("#email").val(),
                    "userName":$("#userName").val(),
                    "userPhone":$("#userPhone").val(),
                    "sex":$(".sexRadio").val()
                },
                "success":function (result) {
                    if(result=='true'){
                        alert("修改成功");
                        userInfoList();
                    }
                }
            });
        });
        //$("#sub").click(updateInfo($("#email").val()));
    });

</script>
</body>
<script>

</script>
</html>